<template>
	<view class="admin-container">
		<button class="admin-btn" @tap="goPicture">轮播图控制</button>
		<button class="admin-btn" @tap="goNotice">发布公告</button>
		<button class="admin-btn" @tap="goUser" v-if="data.role==2">用户管理</button>
	</view>
</template>

<script>
	import {onMounted,reactive} from 'vue'
	import global from '../../config/global.js'
	export default {
		name:"admin",
		setup(){
			let data = reactive({
				role:1
			})
			
			onMounted(()=>{
				uni.request({
					url:global.BASE_URL+'/user/rolelevel',
					method:"GET",
					header:{
						"mytoken":uni.getStorageSync("localtoken")
					},
					success:(res)=>{
						if(res.data.code) data.role = res.data.data
					},
					fail:(err)=>{
						console.log(err)
					}
				})
			})
			
			function goPicture(){
				uni.navigateTo({
					url:"../admin/admin-picture"
				})
			}
			
			function goNotice(){
				uni.navigateTo({
					url:"../admin/admin-notice"
				})
			}
			
			function goUser(){
				uni.navigateTo({
					url:"../admin/admin-user"
				})
			}
			
			return {
				data,
				goPicture,
				goNotice,
				goUser
			}
		}
	}
</script>

<style>
	.admin-container{
		width: 750rpx;
	}
	
	.admin-btn{
		width: 400rpx;
		margin: 40rpx 175rpx;
		height: 70rpx;
		line-height: 70rpx;
		background-color: #9BCDD2;
		color: white;
	}
</style>
